package com.jr.service.impl;

import com.jr.dao.UserDao;
import com.jr.dao.impl.UserDaoImpl;
import com.jr.entity.User;
import com.jr.service.UserService;

import java.util.Objects;

/**
 * @Function：
 * @Author 梁明哲
 * @Email 424577090@qq.com
 * @Package com.jr.service.impl
 * @Project InvoiceManage
 * @Date 2023-02-20 09:11:08
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    /**
     * 根据用户账号登录
     * @param user 用户对象
     * @return 返回user对象
     * @throws Exception
     */

    @Override
    public User login(User user) throws Exception {
        User userDB = userDao.findUsersByAccount(user.getAccount());
        if(Objects.isNull(userDB)){
            return null;
        }
        String password = user.getPassword();
        if(!Objects.equals(userDB.getPassword(),password)){
            return null;
        }
        return userDB;
    }
}







